/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package test;

import javax.swing.*;
import java.awt.event.*;
import javax.swing.table.*;

public class InsertRows{
  public static void main(String[] args) {
    new InsertRows();
  }

  public InsertRows(){
    JFrame frame = new JFrame("Inserting rows in the table!");
    JPanel panel = new JPanel();
    panel.setLayout(null);
    String data[][] = {{"Name","Address"}};
    String col[] = {"",""};
    final DefaultTableModel model = new DefaultTableModel(data,col);
    JTable table = new JTable(model);
    JButton b=new JButton("Add Row");
    b.addActionListener(new ActionListener(){
        public void actionPerformed(ActionEvent e){
        model.insertRow(1,new Object[]{"Roseindia","Delhi"});
        }
    });
    table.setBounds(10,10,300,100);
    b.setBounds(10,120,100,20);
    panel.add(table);
    panel.add(b);
    frame.add(panel);
    frame.setSize(500,200);
    frame.setVisible(true);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  }
}